﻿@model List<SelectListItem>
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
    string[,] str =
{       // 名称，方法
        {"菜单列表","Index" }//,
        //{"最少转机","Least" }
    };
}
<div class="layui-tab layui-tab-brief">
    <ul class="layui-tab-title title-pin">
        @{
            for (int i = 0; i < str.Length / 2; i++) {
                <li class="@(i==0?"layui-this":"")">@str[i, 0]</li>
            }
        }
    </ul>
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
            <form method="post" class="layui-form">
                <div class="layui-form-item">
                    <label class="layui-form-label">侧边栏</label>
                    <div class="layui-input-block">
                        <select name="ID" lay-filter="sel">
                            @foreach (var item in Model) {
                                <option value="@item.Value">@Html.Raw(item.Text)</option>
                            }
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"> 标 题 </label>
                    <div class="layui-input-block">
                        <input type="text" name="Title" placeholder="请输入标题" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"> 地 址 </label>
                    <div class="layui-input-block">
                        <input type="text" name="Url" placeholder="请输入地址" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"> 图 标 </label>
                    <div class="layui-input-block">
                        <input type="text" name="Icon" placeholder="例如：fa-*" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"> 信 息 </label>
                    <div class="layui-input-block">
                        <textarea name="Info" class="layui-textarea" placeholder="请输入相关信息"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">

                        <div class="layui-btn-group">
                            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="btn"
                                    data-url="@Url.Action("Edit", "AddNav")">
                                保存更改
                            </button>
                            <label class="layui-btn layui-btn-normal" lay-submit onclick="GetNav()">
                                读取数据
                            </label>
                        </div>
                        <div class="layui-btn-group">
                            <button class="layui-btn" lay-submit lay-filter="btn"
                                    data-url="@Url.Action("Insert", "AddNav")">
                                添加下级
                            </button>

                            <button class="layui-btn layui-btn-danger" lay-submit lay-filter="btn"
                                    data-url="@Url.Action("Delete", "AddNav")">
                                删除选项
                            </button>
                        </div>

                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

@section jq{
    <script>

        function GetNav() {
            var val = $("select[name=ID]").val();
            if (val == "0") {
                layer.msg("请选择其它项！");
                return;
            }
            $.post("/AddNav/GetNav", { ID: val }, function (res) {
                $("input[name=Title]").val(res.Title);
                $("input[name=Url]").val(res.Url);
                $("input[name=Icon]").val(res.Icon);
                $("textarea[name=Info]").val(res.Info);
            }, "JSON");
        }

    </script>

}